<#include "/common/dialogbox.html">
<@header>
</@header>
<@body>
  <div class="x_content">
	<form class="form-horizontal form-label-left" method="post" action="${ctx}/system/user/doEdit" id="userEditForm">
		<input type="hidden" value="${sysUser.id}" name="id">
		<div class="form-group">
			<label class="control-label col-md-2 col-sm-2 col-xs-12">
				用户名称 <span class="required">*</span>
			</label>
			<div class="col-md-9 col-sm-9 col-xs-12">
				<input type="text" id="userName" name="userName" value="${(sysUser.userName)!}" class="form-control" placeholder="请输入用户名" required>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label col-md-2 col-sm-2 col-xs-12">
				用户部门 <span class="required">*</span>
			</label>
			<div class="col-md-9 col-sm-9 col-xs-12">
				<select name="deptId" class="form-control select2" style="width: 100%;" required>
					<option value="" selected="selected">--请选择--</option>
					<#list deptList as dept>
						<option value="${(dept.id)!}" ${(sysUser.deptId?? && dept.id==sysUser.deptId)?string('selected="selected"','')}>${(dept.deptName)!}</option>
					</#list>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label col-md-2 col-sm-2 col-xs-12">
				用户密码 <span class="required">*</span>
			</label>
			<div class="col-md-9 col-sm-9 col-xs-12">
				<input type="password" class="form-control" id="password" name="password" placeholder="密码为空则不修改密码">
			</div>
		</div>
		<div class="form-group">
			<label class="control-label col-md-2 col-sm-2 col-xs-12">
				用户描述 <span class="required">*</span>
			</label>
			<div class="col-md-9 col-sm-9 col-xs-12">
				<textarea class="form-control" name="userDesc" rows="3" placeholder="请输入描述，最多300个字符 ..." required>${(sysUser.userDesc)!}</textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label col-md-2 col-sm-2 col-xs-12">
				用户状态 <span class="required">*</span>
			</label>
			<div class="col-md-9 col-sm-9 col-xs-12">
				<label class="radio-box">
					<input name="userState" type="radio" class="flat" ${(sysUser.userState==1)?string('checked','')} value="1" required> 启用
				</label>
				<label class="radio-box">
					<input name="userState" type="radio" class="flat" ${(sysUser.userState==-1)?string('checked','')} value="-1" required> 禁用
				</label>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label col-md-2 col-sm-2 col-xs-12">
				用户角色 <span class="required">*</span>
			</label>
			<div class="col-md-9 col-sm-9 col-xs-12">
				<#list sysRoles as role>
				<label class="check-box" title="${(role.roleDesc)!}">
					<input type="checkbox" name="roleId[]" class="flat" value="${(role.id)!}"${(myRolds?seq_contains('${role.id}')?string('checked',''))} >
					${(role.roleName)!}
				</label> &nbsp;
				</#list>
			</div>
		</div>
	</form>
</div>
</@body>
<@footer>
<script type="text/javascript">
	function submitHandler() {
		if ($("#userEditForm").validate().form()) {
			var formData = $("#userEditForm").serialize();
			$.ajax({
				url : $("#userEditForm").attr('action'),
				type : 'POST',
				dataType : "json",
				data : formData,
				success : function(data) {
					if (data.code == 200) {
						if (data.msg) {
							parent.layer.msg(data.msg, {
								icon : 1
							});
						} else {
							parent.layer.msg('提交成功', {
								icon : 1
							});
						}
						window.parent.refreshTable();
						parent.layer.closeAll('iframe');
					} else {
						layer.msg(data.msg, {
							icon : 2
						});
					}
				}
			});
		}
	}
</script>
</@footer>
